<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>简历列表</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
</head>
<body>
    <div th:replace="common/header :: header"></div>

    <div class="container mt-5">
        <div class="card shadow rounded-4">
            <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center rounded-top-4">
                <h5 class="mb-0"><i class="bi bi-file-earmark-text"></i> 简历管理</h5>
                <a th:href="@{/resume/add}" class="btn btn-success">
                    <i class="bi bi-plus-circle"></i> 新建简历
                </a>
            </div>
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped table-hover align-middle">
                        <thead class="table-light">
                            <tr>
                                <th>ID</th>
                                <th>申请人</th>
                                <th>应聘职位</th>
                                <th>学历</th>
                                <th>学校</th>
                                <th>专业</th>
                                <th>工作经验</th>
                                <th>技能</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="resume : ${resumes}">
                                <td th:text="${resume.id}"></td>
                                <td th:text="${resume.user?.realName}"></td>
                                <td th:text="${resume.job?.title}"></td>
                                <td th:text="${resume.education}"></td>
                                <td th:text="${resume.school}"></td>
                                <td th:text="${resume.major}"></td>
                                <td th:text="${resume.workExperience}"></td>
                                <td th:text="${resume.skills}"></td>
                                <td>
                                    <span th:class="${'badge ' + (resume.status == 'PENDING' ? 'bg-warning' : 
                                                             resume.status == 'ACCEPTED' ? 'bg-success' : 
                                                             resume.status == 'REJECTED' ? 'bg-danger' : 'bg-secondary')}"
                                          th:text="${resume.status == 'PENDING' ? '待处理' : 
                                                  resume.status == 'ACCEPTED' ? '已通过' : 
                                                  resume.status == 'REJECTED' ? '已拒绝' : resume.status}">
                                    </span>
                                </td>
                                <td th:text="${#temporals.format(resume.createTime, 'yyyy-MM-dd HH:mm')}"></td>
                                <td>
                                    <div class="btn-group">
                                        <a th:href="@{/resume/edit/{id}(id=${resume.id})}" class="btn btn-sm btn-info">
                                            <i class="bi bi-pencil"></i>
                                        </a>
                                        <button class="btn btn-sm btn-danger" th:onclick="'deleteResume(' + ${resume.id} + ')'">
                                            <i class="bi bi-trash"></i>
                                        </button>
                                        <a th:href="@{/interview/resume/{id}(id=${resume.id})}" class="btn btn-sm btn-primary">
                                            <i class="bi bi-calendar-check"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        function deleteResume(id) {
            if (confirm('确定要删除这份简历吗？')) {
                $.post('/resume/delete/' + id, function(response) {
                    if (response === 'success') {
                        location.reload();
                    } else {
                        alert('删除失败');
                    }
                });
            }
        }
    </script>
</body>
</html> 